package com.ziyun.erp.web.modules.quotePrintFactoryPrice.controller;

import com.ziyun.erp.modules.quotePrintFactoryPrice.entity.QuotePrintFactoryPriceEntity;
import com.ziyun.erp.modules.quotePrintFactoryPrice.service.QuotePrintFactoryPriceService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 工厂印刷机价格表
 *
 * @author llc
 * @email 
 * @date 2018-09-08 16:10:31
 */
@RestController
@RequestMapping("quotePrintFactoryPrice/quoteprintfactoryprice")
public class QuotePrintFactoryPriceController {
    @Autowired
    private QuotePrintFactoryPriceService quotePrintFactoryPriceService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("quotePrintFactoryPrice:quoteprintfactoryprice:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = quotePrintFactoryPriceService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("quotePrintFactoryPrice:quoteprintfactoryprice:info")
    public R info(@PathVariable("id") Integer id){
        QuotePrintFactoryPriceEntity quotePrintFactoryPrice = quotePrintFactoryPriceService.selectById(id);

        return R.ok().put("quotePrintFactoryPrice", quotePrintFactoryPrice);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("quotePrintFactoryPrice:quoteprintfactoryprice:save")
    public R save(@RequestBody QuotePrintFactoryPriceEntity quotePrintFactoryPrice){
        quotePrintFactoryPriceService.insert(quotePrintFactoryPrice);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("quotePrintFactoryPrice:quoteprintfactoryprice:update")
    public R update(@RequestBody QuotePrintFactoryPriceEntity quotePrintFactoryPrice){
        ValidatorUtils.validateEntity(quotePrintFactoryPrice);
        quotePrintFactoryPriceService.updateAllColumnById(quotePrintFactoryPrice);//全部更新
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("quotePrintFactoryPrice:quoteprintfactoryprice:delete")
    public R delete(@RequestBody Integer[] ids){
        quotePrintFactoryPriceService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
